// 注册
$('.zhuce').click(function() {
    getReg()
})

function getReg() {
    $.ajax({
        url: "../php/zhuce.php",
        type: "post",
        data: {
            // userName: $("#uName").val(),
            // userPwd: $("#uPwd").val(),
            username: $('.humin').val(),
            userpass: $('.mima').val()
        },
        success: function(account) {
            // debugge
            console.log(account);
            if (account == 1) {
                alert("账号已注册");
            } else {
                alert("注册成功 去登录");
                window.location.href = '../html/denlu.html';
            }
        }
    })
}

//登录

$('.denlu').click(function() {
    getLog()
})

function getLog() {
    $.ajax({
        url: "../php/denglu.php",
        type: "POST",
        data: {
            username: $(".humin").val(),
            userpass: $(".mima").val(),
        },
        success: function(res) {
            // debugger
            console.log(res);
            if (res == "success") {
                alert("登录成功");
                let res = {
                    userName: 'qqq',
                    id: '1'
                }
                window.location.href = '../html/index.html';
                localStorage.setItem('login', JSON.stringify(res));
            } else {
                alert('账号密码错误或不存在');
            }
        }
    })
}